<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .wrapper {
            width: 400px;
            margin: 0 auto;/*居中*/
            border: 5px solid aqua;
            overflow: hidden;
            /*清除浮动方法2*/
        }

        /*清除浮动方法3*/
        /*.wrapper::after {
            content: "";
            display: block;
            clear: both;
        }*/

        .box1,
        .box2 {
            width: 200px;
            height: 150px;
        }

        .box1 {
            background-color: #ff0000;
            float: left;
        }

        .box2 {
            background-color: green;
            float: right;
        }

        .clear {
            clear: both;
        }

        .box3 {
            background-color: pink;
            width: 200px;
            height: 150px;
        }
    </style>
</head> 
<body>
    <div class="wrapper">
    <div class="box1">box1</div>
    <div class="box2">box2</div>
      <!-- 清除浮动方法1 -->
    <div class="clear"></div>   
    <div class="box3">box3</div>
</div>

    <div class="wrapper">
        <div class="box1">box1</div>
        <div class="box2">box2</div>
    </div>
        <div class="box3">box3</div> 
</body>

</html>